﻿using System;
using System.Web.Mvc;
using System.Web.Security;
using System.Linq;
using Utl;
using System.Collections.Generic;
using System.Reflection;
using Entity;
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public sealed class AllowAnonymousAttribute : Attribute { }

[AttributeUsage(AttributeTargets.All)]
public class JsonIgnoreAttribute : Attribute
{
    public List<string> IgnoreProperties { get; set; }
    public JsonIgnoreAttribute(params string[] properties)
    {
        IgnoreProperties = new List<string>();
        IgnoreProperties.AddRange(properties);
    }
}

public sealed class LogonRequired : AuthorizeAttribute
{
    public override void OnAuthorization(AuthorizationContext filterContext)
    {
        bool skipAuthorization = filterContext.ActionDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true)
        || filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true);
        if (!skipAuthorization)
        {
            base.OnAuthorization(filterContext);
        }
    }
}
